home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / SoundInput.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-07  |  10.6 KB  |  261 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.1 in “MPW Latest” on ETO #19
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __SOUNDINPUT__
  21. #define __SOUNDINPUT__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLEEVENTS__
  30. #include <AppleEvents.h>
  31. #endif
  32. /*    #include <Errors.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <OSUtils.h>                                        */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <Quickdraw.h>                                    */
  38. /*            #include <QuickdrawText.h>                            */
  39. /*    #include <EPPC.h>                                            */
  40. /*        #include <AppleTalk.h>                                    */
  41. /*        #include <Files.h>                                        */
  42. /*            #include <Finder.h>                                    */
  43. /*        #include <PPCToolbox.h>                                    */
  44. /*        #include <Processes.h>                                    */
  45. /*    #include <Notification.h>                                    */
  46.  
  47. #ifndef __WINDOWS__
  48. #include <Windows.h>
  49. #endif
  50. /*    #include <Controls.h>                                        */
  51. /*        #include <Menus.h>                                        */
  52.  
  53. #ifndef __DIALOGS__
  54. #include <Dialogs.h>
  55. #endif
  56. /*    #include <TextEdit.h>                                        */
  57.  
  58. #ifndef __FILES__
  59. #include <Files.h>
  60. #endif
  61.  
  62. #ifndef __SOUND__
  63. #include <Sound.h>
  64. #endif
  65. /*    #include <Components.h>                                        */
  66.  
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70.  
  71. #if PRAGMA_ALIGN_SUPPORTED
  72. #pragma options align=mac68k
  73. #endif
  74.  
  75. #if PRAGMA_IMPORT_SUPPORTED
  76. #pragma import on
  77. #endif
  78.  
  79.  
  80. enum {
  81.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  82.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  83.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  84.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  85.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  86. };
  87.  
  88. enum {
  89. /*Info Selectors for Sound Input Drivers*/
  90.     siActiveChannels            = 'chac',                        /*active channels*/
  91.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  92.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  93.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  94.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  95.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  96.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  97.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  98.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  99.     siCompressionType            = 'comp',                        /*current compression type*/
  100.     siContinuous                = 'cont',                        /*continous recording*/
  101.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  102.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  103.     siDeviceIcon                = 'icon',                        /*input device icon*/
  104.     siDeviceName                = 'name',                        /*input device name*/
  105.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  106.     siInputGain                    = 'gain',                        /*input gain*/
  107.     siInputSource                = 'sour',                        /*input source selector*/
  108.     siInputSourceNames            = 'snam',                        /*input source names*/
  109.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  110.     siModemGain                    = 'mgai',                        /*modem input gain*/
  111.     siNumberChannels            = 'chan',                        /*current number of channels*/
  112.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  113.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  114.     siRecordingQuality            = 'qual',                        /*recording quality*/
  115.     siSampleRate                = 'srat',                        /*current sample rate*/
  116.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  117.     siSampleSize                = 'ssiz',                        /*current sample size*/
  118.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  119.     siSetupCDAudio                = 'sucd',                        /*setup sound hardware for CD audio*/
  120.     siSetupModemAudio            = 'sumd',                        /*setup sound hardware for modem audio*/
  121.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  122.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  123.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  124.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  125.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  126.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  127.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  128.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  129. /*Qualities*/
  130.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  131.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  132.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  133.     siGoodQuality                = 'good'
  134. };
  135.  
  136. typedef struct SPB SPB, *SPBPtr;
  137.  
  138. /*user procedures called by sound input routines*/
  139. /*
  140.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  141.         be written in or called from a high-level language without the help of
  142.         mixed mode or assembly glue.
  143.  
  144.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  145.  
  146.         In:
  147.          => inParamPtr      A0.L
  148.          => dataBuffer      A1.L
  149.          => peakAmplitude    D0.W
  150.          => sampleSize      D1.L
  151. */
  152. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  153.  
  154. #if GENERATINGCFM
  155. typedef UniversalProcPtr SIInterruptUPP;
  156. typedef UniversalProcPtr SICompletionUPP;
  157. #else
  158. typedef Register68kProcPtr SIInterruptUPP;
  159. typedef SICompletionProcPtr SICompletionUPP;
  160. #endif
  161.  
  162. struct SPB {
  163.     long                            inRefNum;                    /*reference number of sound input device*/
  164.     unsigned long                    count;                        /*number of bytes to record*/
  165.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  166.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  167.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  168.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  169.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  170.     long                            userLong;                    /*user-defined field*/
  171.     OSErr                            error;                        /*error*/
  172.     long                            unused1;                    /*reserved - must be zero*/
  173. };
  174. extern pascal NumVersion SPBVersion(void)
  175.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  176. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  177.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  178. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  179.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  180. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  181.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  182. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  183.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  184. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  185.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  186. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  187.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  188. extern pascal OSErr SPBCloseDevice(long inRefNum)
  189.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  190. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  191.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  192. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  193.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  194. extern pascal OSErr SPBPauseRecording(long inRefNum)
  195.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  196. extern pascal OSErr SPBResumeRecording(long inRefNum)
  197.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  198. extern pascal OSErr SPBStopRecording(long inRefNum)
  199.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  200. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  201.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  202. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  203.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  204. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  205.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  206. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  207.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  208. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  209.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  210. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  211.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  212. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  213.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  214. enum {
  215.     uppSIInterruptProcInfo = kRegisterBased
  216.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  217.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  218.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  219.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  220.     uppSICompletionProcInfo = kPascalStackBased
  221.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  222. };
  223.  
  224. #if GENERATINGCFM
  225. #define NewSIInterruptProc(userRoutine)        \
  226.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  227. #define NewSICompletionProc(userRoutine)        \
  228.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  229. #else
  230. #define NewSIInterruptProc(userRoutine)        \
  231.         ((SIInterruptUPP) (userRoutine))
  232. #define NewSICompletionProc(userRoutine)        \
  233.         ((SICompletionUPP) (userRoutine))
  234. #endif
  235.  
  236. #if GENERATINGCFM
  237. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  238.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  239. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  240.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  241. #else
  242. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  243. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  244.         (*(userRoutine))((inParamPtr))
  245. #endif
  246.  
  247.  
  248. #if PRAGMA_IMPORT_SUPPORTED
  249. #pragma import off
  250. #endif
  251.  
  252. #if PRAGMA_ALIGN_SUPPORTED
  253. #pragma options align=reset
  254. #endif
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259.  
  260. #endif /* __SOUNDINPUT__ */
  261.